package org.sprong.generagor.domain.entity;

import lombok.Builder;
import lombok.Data;
import org.apache.catalina.User;
import org.sprong.generagor.infra.enums.SexEnum;

/**
 * @author guoqiang.lv 2021/10/16
 */
@Data
@Builder
public class UserVO {
    private String name;
    private String sex;
    private String tel;
    private String email;
    private Integer age;
    private AddressVO address;

    public static UserVO generateRandomUser(AddressGenerator addressGenerator) {
        // age
        int age = NameGenerator.getNum(12, 40);
        // sex
        SexEnum sexEnum = SexEnum.generateSex();
        // name
        String name = NameGenerator.getName(sexEnum);
        // tel
        String tel = NameGenerator.getTel();
        // email
        String email = NameGenerator.getEmail();

        AddressVO addressVO = addressGenerator.getAddress();

        return UserVO.builder().age(age).sex(sexEnum.getMeaning()).name(name).tel(tel).email(email)
                .address(addressVO).build();
    }

    public static UserVO generateRandomUser(AddressVO addressVO) {
        // age
        int age = NameGenerator.getNum(12, 40);
        // sex
        SexEnum sexEnum = SexEnum.generateSex();
        // name
        String name = NameGenerator.getName(sexEnum);
        // tel
        String tel = NameGenerator.getTel();
        // email
        String email = NameGenerator.getEmail();

        return UserVO.builder().age(age).sex(sexEnum.getMeaning()).name(name).tel(tel).email(email)
                .address(addressVO).build();
    }

    public String format() {
        return String.format("%s,%s,%s,%s,%s", name, sex, age, email, address.getProvince()
                + address.getCity() + address.getCounty() + address.getTown());
    }
}
